<?php

add_action('init','of_options');

if (!function_exists('of_options'))
{
	function of_options()
	{
		//Access the WordPress Categories via an Array
		$of_categories = array();  
		$of_categories_obj = get_categories('hide_empty=0');
		foreach ($of_categories_obj as $of_cat) {
		    $of_categories[$of_cat->cat_ID] = $of_cat->cat_name;}
		$categories_tmp = array_unshift($of_categories, "Select a category:"); 

		//Access the WordPress Categories via an Array for mutlicheck
		
		$the_categories = get_categories('hide_empty=0');
		
		foreach($the_categories as $category){
    		$category_array[$category->cat_ID] = $category->cat_name;
			}

		$my_categories = $category_array;
	       
		//Access the WordPress Pages via an Array
		$of_pages = array();
		$of_pages_obj = get_pages('sort_column=post_parent,menu_order');    
		foreach ($of_pages_obj as $of_page) {
		    $of_pages[$of_page->ID] = $of_page->post_name; }
		$of_pages_tmp = array_unshift($of_pages, "Select a page:");       
	
		//Testing 
		$of_options_select = array("one","two","three","four","five"); 
		$of_options_radio = array("one" => "One","two" => "Two","three" => "Three","four" => "Four","five" => "Five");
		
		//Sample Homepage blocks for the layout manager (sorter)
		$of_options_homepage_blocks = array
		( 
			"disabled" => array (
				"placebo" 		=> "placebo", //REQUIRED!
				"block_one"		=> "Block One",
				"block_two"		=> "Block Two",
				"block_three"	=> "Block Three",
			), 
			"enabled" => array (
				"placebo" => "placebo", //REQUIRED!
				"block_four"	=> "Block Four",
			),
		);

		//Default RSS URL
		$default_feed = get_bloginfo('rss2_url');
		
		//Stylesheets Reader
		$alt_stylesheet_path = LAYOUT_PATH;
		$alt_stylesheets = array();
		
		if ( is_dir($alt_stylesheet_path) ) 
		{
		    if ($alt_stylesheet_dir = opendir($alt_stylesheet_path) ) 
		    { 
		        while ( ($alt_stylesheet_file = readdir($alt_stylesheet_dir)) !== false ) 
		        {
		            if(stristr($alt_stylesheet_file, ".css") !== false)
		            {
		                $alt_stylesheets[] = $alt_stylesheet_file;
		            }
		        }    
		    }
		}


		//Background Images Reader
		$bg_images_path = get_stylesheet_directory() . '/framework/images/bgs/'; // change this to where you store your bg images
		$bg_images_url = get_template_directory_uri().'/framework/images/bgs/'; // change this to where you store your bg images
		$bg_images = array();
		
		if ( is_dir($bg_images_path) ) {
		    if ($bg_images_dir = opendir($bg_images_path) ) { 
		        while ( ($bg_images_file = readdir($bg_images_dir)) !== false ) {
		            if(stristr($bg_images_file, ".png") !== false || stristr($bg_images_file, ".jpg") !== false) {
		                $bg_images[] = $bg_images_url . $bg_images_file;
		            }
		        }    
		    }
		}
		

		/*-----------------------------------------------------------------------------------*/
		/* TO DO: Add options/functions that use these */
		/*-----------------------------------------------------------------------------------*/
		
		//More Options
		$uploads_arr = wp_upload_dir();
		$all_uploads_path = $uploads_arr['path'];
		$all_uploads = get_option('of_uploads');
		$other_entries = array("Select a number:","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19");
		$body_repeat = array("no-repeat","repeat-x","repeat-y","repeat");
		$body_pos = array("top left","top center","top right","center left","center center","center right","bottom left","bottom center","bottom right");
		$bg_att = array("scroll", "fixed");
		
		// Image Alignment radio box
		$of_options_thumb_align = array("alignleft" => "Left","alignright" => "Right","aligncenter" => "Center"); 
		
		// Image Links to Options
		$of_options_image_link_to = array("image" => "The Image","post" => "The Post"); 


/*-----------------------------------------------------------------------------------*/
/* The Options Array */
/*-----------------------------------------------------------------------------------*/

// Set the Options Array
global $of_options;
$of_options = array();

/* ------------------------------------------------------------------------ */
/* General Settings
/* ------------------------------------------------------------------------ */

$of_options[] = array( "name" => "General",
					   "type" => "heading");
					   
$of_options[] = array( "name" => '',
					"desc" => "",
					"id" => "permission_box",
					"std" => "",
					"icon" => false,
					"type" => "permissions");
					
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "general_options",
					"std" => "<h4>General Settings</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => "Enable Responsive Layout",
					"desc" => "Check to enable the Responsive Layout.",
					"id" => "responsive",
					"std" => 0,
					"type" => "checkbox");
					
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "logo_title",
					"std" => "<h4>Favicon</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => __('Custom Favicon', 'framework'),
					"desc" => "Upload a 16px x 16px Png/Gif image that will represent your website\'s favicon.",
					"id" => "favicon",
					"std" => "",
					"type" => "upload");

/* ------------------------------------------------------------------------ */
/* Header
/* ------------------------------------------------------------------------ */

$of_options[] = array( "name" => "Header",
					   "type" => "heading");
					   
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "phone_email_icons_title",
					"std" => "<h4>Top Phone, Address &amp; Intro Text</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => "Header Telephone Number",
                    "desc" => "Enter the telephone number content.",
                    "id" => "top_phone",
                    "std" => "1-800-643-4300",
                    "type" => "text");
					
$of_options[] = array( "name" => "Header Mailing Address",
                    "desc" => "Enter the mailing address.",
                    "id" => "top_mail",
                    "std" => "E104 Dharti II, Ahmedabad, Gujarat, India.",
                    "type" => "text");

$of_options[] = array( "name" => "Header Intro Text",
                    "desc" => "Enter a short intro text.",
                    "id" => "top_text",
                    "std" => "Admission Open for 2012 click here to Get Form",
                    "type" => "textarea");
					   
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "social_icons_title",
					"std" => "<h4>Social Icons</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => "Enable the top page social icons",
					"desc" => "Check to enable the top page social icons.",
					"id" => "top_icons_enable",
					"std" => 0,
					"folds" => 0,
					"type" => "checkbox");
					
$of_options[] = array( "name" => "Facebook Profile Url",
                				    "desc" => "Enter the URL to your Facebook Account.",
				                    "id" => "social_facebook",
				                    "std" => "http://facebook.com/skatdesign",
									"fold" => 'top_icons_enable',
				                    "type" => "text");
									
$of_options[] = array( "name" => "LinkedIn Profile Url",
                				    "desc" => "Enter the URL to your LinkedIn Account.",
				                    "id" => "social_linkedin",
				                    "std" => "http://www.linkedin.com/in/skatdesign",
									"fold" => 'top_icons_enable',
				                    "type" => "text");
					
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "logo_title",
					"std" => "<h4>Logo</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => __('Custom Logo', 'framework'),
					"desc" => "Upload a logo for your theme, or specify the image address of your online logo. (http://yoursite.com/logo.png).",
					"id" => "logo",
					"std" => "",
					"type" => "upload");

$of_options[] = array( "name" => "Logo Top Margin (without px)",
                    "desc" => "Enter the logo's top margin (Default: 40).",
                    "id" => "logo_top_margin",
                    "std" => "8",
                    "type" => "text");
					
$of_options[] = array( "name" => "Logo Left Margin (without px)",
                    "desc" => "Enter the logo's left margin (Default: 0).",
                    "id" => "logo_left_margin",
                    "std" => "18",
                    "type" => "text");
					
/* ------------------------------------------------------------------------ */
/* Featured Slider
/* ------------------------------------------------------------------------ */

$of_options[] = array( "name" => "Home Slider",
					   "type" => "heading");
					   
$of_options[] = array( "name" => "Enable the Home Featured Slider",
					"desc" => "Check to enable the homepage slider.",
					"id" => "slider_enable",
					"std" => 0,
					"folds" => 0,
					"type" => "checkbox");
					
					$of_options[] = array( "name" => __('Featured Slider', 'framework'),
											"desc" => __('Enable or disable the homepage featured slider', 'framework'),
											"id" => "featured_slider",
											"std" => '',
											"fold" => 'slider_enable',
											"type" => "slider");
					   
/* ------------------------------------------------------------------------ */
/* Search Box
/* ------------------------------------------------------------------------ */

$of_options[] = array( "name" => "Search Box",
					   "type" => "heading");
					   
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "search_box_title",
					"std" => "<h4>Search Box Settings</h4>",
					"icon" => true,
					"type" => "info");

$of_options[] = array( "name" => "Show Homepage Search Box",
					"desc" => "Check to show the homepage Search Bar.",
					"id" => "search_box",
					"folds" => 0,
					"std" => 0,
					"type" => "checkbox");
					
				$of_options[] = array( "name" => "",
									"desc" => "",
									"id" => "search_box_one_title",
									"fold" => 'search_box',
									"std" => "<h4>First Field Settings</h4>",
									"icon" => true,
									"type" => "info");
									
				$of_options[] = array( "name" => "First Field Title",
				                    "desc" => "Enter the title of the first field.",
                				    "id" => "first_field_title",
									"fold" => 'search_box',
				                    "std" => "Course Name",
				                    "type" => "text");
									
				$of_options[] = array( "name" => "Categories for search field 1",
									"desc" => "Select desired categories.",
									"id" => "categories_box_one",
									"fold" => 'search_box',
									"std" => array("1"),
									"options" => $my_categories,
									"type" => "multicheck");
									
				$of_options[] = array( "name" => "",
									"desc" => "",
									"id" => "search_box_two_title",
									"fold" => 'search_box',
									"std" => "<h4>Second Field Settings</h4>",
									"icon" => true,
									"type" => "info");
									
				$of_options[] = array( "name" => "Second Field Title",
				                    "desc" => "Enter the title of the second field.",
                				    "id" => "second_field_title",
									"fold" => 'search_box',
				                    "std" => "Course Length",
				                    "type" => "text");
					
				$of_options[] = array( "name" => "Categories for search field 2",
									"desc" => "Select desired categories.",
									"id" => "categories_box_two",
									"fold" => 'search_box',
									"std" => array("1"),
									"options" => $my_categories,
									"type" => "multicheck");
									
				$of_options[] = array( "name" => "",
									"desc" => "",
									"id" => "search_box_three_title",
									"fold" => 'search_box',
									"std" => "<h4>Third Field Settings</h4>",
									"icon" => true,
									"type" => "info");
									
				$of_options[] = array( "name" => "Third Field Title",
				                    "desc" => "Enter the title of the third field.",
                				    "id" => "third_field_title",
									"fold" => 'search_box',
				                    "std" => "Select Nearest College Location",
				                    "type" => "text");
					
				$of_options[] = array( "name" => "Categories for search field 3",
									"desc" => "Select desired categories.",
									"id" => "categories_box_three",
									"fold" => 'search_box',
									"std" => array("1"),
									"options" => $my_categories,
									"type" => "multicheck");

					
/* ------------------------------------------------------------------------ */
/* Footer
/* ------------------------------------------------------------------------ */

$of_options[] = array( "name" => "Footer",
					   "type" => "heading");
					   
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "footer_title",
					"std" => "<h4>Footer Settings</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => "Twitter Username",
                    "desc" => "Enter your Twitter Username.",
                    "id" => "twitter_username",
                    "std" => "skatdesign",
                    "type" => "text");
					
$of_options[] = array( "name" => "Newsletter Feedburner RSS id",
                    "desc" => "Enter your feedburner rss id (eg. skatdesign).",
                    "id" => "feedburner_id",
                    "std" => "skatdesign",
                    "type" => "text");
		
$of_options[] = array( "name" => "Custom Copyright Text",
					"desc" => "Insert your custom copyright text.",
					"id" => "copyright",
					"std" => "",
					"type" => "textarea");
					
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "social_icons_footer_title",
					"std" => "<h4>Footer Social Icons</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => "Show Footer Social Icons",
					"desc" => "Check to show Social Icons in the footer.",
					"id" => "social_icons_footer",
					"std" => 0,
          			"folds" => 1,
					"type" => "checkbox");
					
				$of_options[] = array( "name" => "Twitter Username",
                			    "desc" => "Enter your Twitter Username.",
			                    "id" => "social_twitter_footer",
			                    "std" => "skatdesign",
								"fold" => 'social_icons_footer',
			                    "type" => "text");
								
				$of_options[] = array( "name" => "Facebook Profile Url",
                				    "desc" => "Enter the URL to your Facebook Account.",
				                    "id" => "social_facebook_footer",
				                    "std" => "http://facebook.com/skatdesign",
									"fold" => 'social_icons_footer',
				                    "type" => "text");
					
				$of_options[] = array( "name" => "Flickr Url",
                			    "desc" => "Enter the URL to your Flickr Account.",
			                    "id" => "social_flickr_footer",
			                    "std" => "#",
								"fold" => 'social_icons_footer',
			                    "type" => "text");
					
				$of_options[] = array( "name" => "RSS Feed Url",
			                    "desc" => "Enter the URL to your RSS Feed.",
			                    "id" => "social_rss_footer",
			                    "std" => $default_feed,
								"fold" => 'social_icons_footer',
			                    "type" => "text");
								
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "menu_footer_title",
					"std" => "<h4>Footer Menu</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => "Show Footer Menu",
					"desc" => "Check to show the footer menu.",
					"id" => "menu_footer",
					"std" => 0,
					"type" => "checkbox");
								
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "tracking_title",
					"std" => "<h4>Tracking Code</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => "Tracking Code",
					"desc" => "Paste your Google Analytics (or other) tracking code here. This will be added into the footer template of your theme.",
					"id" => "analytics_code",
					"std" => "",
					"type" => "textarea");        

/* ------------------------------------------------------------------------ */
/* Styling
/* ------------------------------------------------------------------------ */
					   
$of_options[] = array( "name" => "Styling",
					   "type" => "heading");
$url =  ADMIN_DIR . 'assets/images/';					   
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "color_styles",
					"std" => "<h4>Color Styles</h4>",
					"icon" => true,
					"type" => "info");
					   
$of_options[] = array( "name" => "Theme Color",
					"desc" => "Select the color for the theme.",
					"id" => "color_style",
					"std" => "style.css",
					"type" => "images",
					"options" => array(
						'style.css' => $url . 'blue.png',
						'style-green.css' => $url . 'green.png',
						'style-orange.css' => $url . 'orange.png'
						)
					);
					
$of_options[] = array( "name" => "",
					"desc" => "",
					"id" => "custom_css_title",
					"std" => "<h4>Custm CSS</h4>",
					"icon" => true,
					"type" => "info");
					
$of_options[] = array( "name" => __('Custom CSS', 'framework'),
                    "desc" => __('Quickly add some CSS to your theme by adding it to this block.', 'framework'),
                    "id" => "custom_css",
                    "std" => "",
                    "type" => "textarea");


/* ------------------------------------------------------------------------ */
/* Blog
/* ------------------------------------------------------------------------ */
					   
$of_options[] = array( "name" => "Blog",
					   "type" => "heading");
					   
$url =  ADMIN_DIR . 'assets/images/';
$of_options[] = array( "name" => "Sidebar Position",
					"desc" => "Select the position of the sidebar (right or left).",
					"id" => "blog_sidebar",
					"std" => "right",
					"type" => "images",
					"options" => array(
						'right' => $url . '2cr.png',
						'left' => $url . '2cl.png',
						)
					);
					
$of_options[] = array( "name" => __('Excerpt Length', 'framework'),
                    "desc" => __('Enter the number of words you want to be displayed as excerpt. (Default: 30)', 'framework'),
                    "id" => "excerpt_length",
                    "std" => "30",
                    "type" => "text");
					
/* ------------------------------------------------------------------------ */
/* Backup Options
/* ------------------------------------------------------------------------ */

$of_options[] = array( "name" => "Backup Options",
					"type" => "heading");
					
$of_options[] = array( "name" => "Backup and Restore Options",
                    "id" => "of_backup",
                    "std" => "",
                    "type" => "backup",
					"desc" => 'You can use the two buttons below to backup your current options, and then restore it back at a later time. This is useful if you want to experiment on the options but would like to keep the old settings in case you need it back.',
					);
					
$of_options[] = array( "name" => "Transfer Theme Options Data",
                    "id" => "of_transfer",
                    "std" => "",
                    "type" => "transfer",
					"desc" => 'You can tranfer the saved options data between different installs by copying the text inside the text box. To import data from another install, replace the data in the text box with the one from another install and click "Import Options".
						',
					);
					
	}
}
?>
